package utils

import (
	"fmt"
)

type ListNode struct {
	Val int
	Next *ListNode
}

func MakeLinkedList(nums []int) *ListNode {
	if len(nums) == 0 {
		return nil
	}

	node := &ListNode{}
	cur := node
	for _, v := range nums {
		cur.Next = &ListNode{
			Val:v,
		}
		cur = cur.Next
	}

	return node.Next
}

func TraverseLinkedList(head *ListNode) {
	cur := head

	for cur != nil {
		fmt.Printf("%v,", cur.Val)
		cur = cur.Next
	}
	fmt.Println("")
}